﻿using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using Microsoft.Phone.Controls;

namespace ZombieMonkeys.Vibria
{
    public partial class OptionsPage : PhoneApplicationPage
    {
        //reference the app page of the application for access to global variables
        GUI.App app;
        
        /// <summary>
        /// Constructor for the options page
        /// </summary>
        public OptionsPage()
        {
            InitializeComponent();



            app = (GUI.App)Application.Current;

            if (app.HintMode == true)
            {
                hintCheckBox.IsChecked = true;
            }
            else
            {
                hintCheckBox.IsChecked = false;
            }
            if (app.PenMode == true)
            {
                penModeCheckBox.IsChecked = true;
            }
            else
            {
                penModeCheckBox.IsChecked = false;
            }
        }

        /// <summary>
        /// Method to handle the hint mode check box
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void hintCheckBox_Checked(object sender, RoutedEventArgs e)
        {
            //this is the spot where we turn the hint button on and off
            if (hintCheckBox.IsChecked == true)
            {
                app.HintMode = true;
            }
            if (hintCheckBox.IsChecked == false)
            {
                app.HintMode = false;
            }
        }

        /// <summary>
        /// Method to handle the pen mode check box
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void penModeCheckBox_Checked(object sender, RoutedEventArgs e)
        {
            //this is the spot where we turn pen mode on and off
            if (penModeCheckBox.IsChecked == true)
            {
                app.PenMode = true;
            }
            if (penModeCheckBox.IsChecked == false)
            {
                app.PenMode = false;
            }
        }


        private void radioButton1_Checked(object sender, RoutedEventArgs e)
        {
            changeWallpaper("WP7a.jpg");
        }
        private void radioButton2_Checked(object sender, RoutedEventArgs e)
        {
            changeWallpaper("WP7b.jpg");
        }
        private void radioButton3_Checked(object sender, RoutedEventArgs e)
        {
            changeWallpaper("WP7c.jpg");
        }
        private void radioButton4_Checked(object sender, RoutedEventArgs e)
        {
            changeWallpaper("WP7d.jpg");
        }

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {

        }

        /// <summary>
        /// Method for changing wallpaper
        /// </summary>
        /// <param name="filePath"></param>
        private void changeWallpaper(string filePath)
        {
            System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
            bmp.UriSource = new Uri(filePath, UriKind.Relative);
            var ImageBrush = new ImageBrush();
            ImageBrush.ImageSource = bmp;
            ImageBrush.Stretch = Stretch.Fill;
            app.RootFrame.Background = ImageBrush;
            List<Control> controls = new List<Control>();
            foreach (UIElement Uielement in LayoutRoot.Children)
            {
                Uielement.GetType();
            }

            

            
        }

        
      
    }
}